import $service from '../../../../service'
const app = getApp()
Page({
  data: {
    titleList: ['体质表现','调理方案'],
    titleType: '体质表现',
    requestId: '',
    expressionData: [],
    projectList: [{
      icon: '/static/images/physique_photo/icon_emotion.png',
      isShow: true
    },{
      icon: '/static/images/physique_photo/icon_diet.png',
      isShow: false
    },{
      icon: '/static/images/physique_photo/icon_daily_life.png',
      isShow: false
    },{
      icon: '/static/images/physique_photo/icon_motion.png',
      isShow: false
    },{
      icon: '/static/images/physique_photo/icon_acupoint.png',
      isShow: false
    }],
    bodyType: ''
  },
  onLoad(e) {
    this.setData({
      requestId: e.requestId
    })
    this.acquireReport()
  },
  titleChange(e) {
    let {type} = e.currentTarget.dataset;
    this.setData({
      titleType: type
    })
  },
  acquireReport() {
    app.http.acquireReport({requestId: this.data.requestId}).then(res => {
      let list = res.data.moduleList.slice(1)
      list.forEach((item, index) => {
        for (let key in  this.data.projectList[index]) {
          item[key] = this.data.projectList[index][key]
        }
      })
      this.setData({
        expressionData: res.data.moduleList[0].descList,
        projectList: list,
        bodyType: res.data.constitution
      })
    }).catch(err => {
      $service.showToast(err.msg)
    })
  }
})